import 'package:citiesocial/_include.dart';
import 'package:citiesocial/ui/goods/goods_by_history.dart';

///
///最近浏览商品
///
class HistoryGoods extends StatelessWidget {
  final List<GoodsEntity> goodsList;

  HistoryGoods(this.goodsList) : super();

  @override
  Widget build(BuildContext context) {
    final widgets = List<Widget>();
    if (goodsList != null) {
      widgets.addAll([
        Container(
          child: Text(
            '最近浏览商品',
            style: TextStyle(fontSize: 20.0, color: Colors.black),
          ),
          padding: EdgeInsets.all(10.0),
        ),
        Container(
          child: Configs.dividerMainColor,
          margin: EdgeInsets.symmetric(horizontal: 100.0),
        ),
      ]);
      for (var goods in goodsList) {
        widgets.add(LongSquareGoodsItem(goods));
      }
      widgets.addAll([
        Container(
          child: Configs.dividerMainColor,
          margin: EdgeInsets.symmetric(horizontal: 20.0),
        ),
        SeeMore(
          onTap: () {
            Navigator.push(context,
                MaterialPageRoute(builder: (context) => GoodsByHistory()));
          },
          title: '更多浏览记录',
        ),
        Container(
          decoration: BoxDecoration(
              shape: BoxShape.rectangle, color: Configs.background),
          height: 10.0,
        ),
      ]);
    }
    return Container(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Center(
            child: Column(
              children: widgets,
            ),
          ),
        ],
      ),
      color: Colors.white,
    );
  }
}
